home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS16.ADF
/
C
/
ShowPrint
/
pdump2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-01-27
|
2KB
|
94 lines
/* Print Dump */
#include <exec/types.h>
#include <intuition/intuition.h>
#include <devices/printer.h>
static struct IODRPReq request;
static struct MsgPort *printerPort;
extern struct MsgPort *CreatePort();
extern void *GetMsg(), *OpenLibrary(), *OpenWindow();
struct IntuitionBase *IntuitionBase;
struct IntuiMessage *mes;
#define ESC 0x45
pdump(w)
struct Window *w;
{
register struct IODRPReq *req=&request;
struct Screen *screen;
struct RastPort *rp;
struct ViewPort *vp;
struct ColorMap *cm;
int width,height;
long error,modes;
ULONG class;
UWORD code;
int result;
screen=w->WScreen;
vp=&screen->ViewPort;
rp=&screen->RastPort;
cm=vp->ColorMap;
modes=vp->Modes;
width=vp->DWidth;
height=vp->DHeight;
if((printerPort=CreatePort(NULL,0L))==NULL)
{
printf("Couldn't Create Port\n");
return(0);
}
if(OpenDevice("printer.device",0L,req,0L))
{
printf("Couldn't open printer device\n");
DeletePort(printerPort);
return(0);
}
req->io_Command=PRD_DUMPRPORT;
req->io_RastPort=rp;
req->io_ColorMap=cm;
req->io_Modes=modes;
req->io_Message.mn_ReplyPort=printerPort;
req->io_SrcX=0;
req->io_SrcY=0;
req->io_SrcWidth=width;
req->io_SrcHeight=height;
req->io_DestCols=width;
req->io_DestRows=height;
req->io_Special=0xCC;
SendIO(req);
while((CheckIO(req))==FALSE)
{
if((mes=(struct IntuiMessage *)GetMsg(w->UserPort))==0L)
{
Wait(1L<<w->UserPort->mp_SigBit);
continue;
}
class=mes->Class;
code=mes->Code;
ReplyMsg(mes);
switch(class)
{
case RAWKEY : if(code==ESC)
{
req->io_Command=CMD_RESET;
BeginIO(req);
WaitIO(req);
goto cleanup3;
}
break;
}
}
cleanup3:
CloseDevice(&request);
cleanup2:
DeletePort(printerPort);
}